﻿using Digitalmes.Domain.Entities.Mes.Processes;

namespace Digitalmes.Application.Mes.Processes.Boms.Commands;

/// <summary>
/// 删除工序 BOM 命令。
/// </summary>
public record DeleteBomCommand(long BomId) : IRequest<IResult<bool>>;

internal sealed class DeleteBomCommandHandler(IRepository<ProcBom> repo) : IRequestHandler<DeleteBomCommand, IResult<bool>>
{
    public async Task<IResult<bool>> Handle(DeleteBomCommand request, CancellationToken cancellationToken)
    {
        var ok = await repo.DeleteByIdAsync(request.BomId, cancellationToken);
        return Result.From(ok);
    }
}
